<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" isELIgnored="false"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet"  type="text/css" href='<c:url value="/resources/jquery-easyui-1.5/themes/default/easyui.css"/>' />
<link rel="stylesheet"  type="text/css" href='<c:url value="/resources/jquery-easyui-1.5/themes/icon.css"/>' />
<script type="text/javascript" src='<c:url value="/resources/jquery-easyui-1.5/jquery.min.js"/>' /></script>
<link rel="stylesheet" type="text/css" href='<c:url value="/resources/kindeditor/themes/default/default.css" />' />
	<link rel="stylesheet" type="text/css" href='<c:url value="/resources/kindeditor/plugins/code/prettify.css" />' />
<script type="text/javascript" src='<c:url value="/resources/jquery-easyui-1.5/jquery.easyui.min.js"/>' ></script>
<script type="text/javascript" src='<c:url value="/resources/jquery-easyui-1.5/locale/easyui-lang-zh_CN.js"/>'></script>
<title>Insert title here</title>
<style>
	.btn-area{
	text-align:center;
	}
	form table tr td input{
		width:100%;
	}
	.text-lable{
		width:50px;
	}
	.panel-header{
		height:30px;
		line-height:30px;
	}
	.panel-title{
		font-size:14px;
		line-height:30px;
	}
	.searchDiv{
		position:absolute;
		right:10px;
		top:4px;
	}
	.searchDiv input{
		border-radius:5px;
		-webkit-border-radius:5px;
		-moz-border-radius:5px;
		-o-border-radius:5px;
		margin:0px 3px;
	}
	.searchDiv>span,.searchDiv>a{
			margin:0px 3px;
	}
</style>
</head>
<body>
	<div style="position:relative;margin:10px;height:30px;">
		<div class="searchDiv">
			<input id="startTime" class="easyui-datetimebox"style="width:150px">
			<span>至</span>
			<input id="endTime" class="easyui-datetimebox" style="width:150px">
			<input id="searchTitle" placeholder="标题" style="width:122px;	border:1px solid #95B8E7;height:20px;line-height:20px;"/>
			<button id="searchBtn">搜索</button>
		</div>
		</div>
	<table id="newsList" class="easyui-datagrid" title="新闻数据列表" Width="100%"></table> 
	<div id="addDialog" class="easyui-dialog" style="width:800px; height:520px;padding:20px 30px;" title="新闻添加" iconCls="icon-add" data-options="closed:true">
         <form id="addNewsForm" action="${basePath }/news/create" method="post">
         	<input type="hidden" id="imgPath" name="imgPath" value="">
	    	<table cellpadding="5" Width="100%">
	    		<tr>
	    			<td class="text-lable">标题:</td>
	    			<td colspan="3"><input type="text" name="title" data-options="required:true"></input></td>
	    		</tr>
	    		<tr>
	    			<td class="text-lable">来源:</td>
	    			<td colspan="3"><input type="text" name="source" data-options="required:true"></input></td>
	    		</tr>
	    		<tr>
	    			<td class="text-lable">创建人:</td>
	    			<td colspan="3"><input  type="text" name="creater" data-options="required:true"></input></td>
	    		</tr>
	    		<tr>
	    			<td class="text-lable">内容:</td>
	    			<td colspan="3"><textarea  id="content" name="content" class="news_textarea" maxlength=2000 ></textarea></td>
	    		</tr>
	    	</table>
	    	 <div class="btn-area">
	    	<input  type="submit" class="btn btn-primary " value="确定" />
   			<input type="reset" class="btn btn-warning " value="重置" />
	    </div>
	    </form>
    </div>
    <div id="editDialog" class="easyui-dialog" style="width:800px; height:520px;padding:20px 30px;" title="新闻编辑" iconCls="icon-edit" data-options="closed:true">
    	<iframe name="left" id="ifr" src="" frameborder="false" scrolling="auto" style="border:none;" width="100%" height="440" allowtransparency="true"></iframe>
    </div>
</body>
<script type="text/javascript" src="${basePath}/resources/kindeditor/kindeditor-min.js"></script>
<script type="text/javascript" src="${basePath}/resources/kindeditor/lang/zh_CN.js"></script>
<script type="text/javascript" src="${basePath}/resources/kindeditor/plugins/code/prettify.js"></script>
<script type="text/javascript" src="${basePath}/resources/js/common.js"></script>
<script type="text/javascript">
var flag = false,fileName;
var columns=[[
              {field:'ID',title:'ID',hidden:true},
              {field:'title',title:'标题'},
              {field:'time',title:'创建时间'},
              {field:'source',title:'来源'},
              {field:'opt',title:'操作',
                  formatter:function(value,rec,index){  
                      var e = '<a id='+rec.ID+' href="javascript:void(0);" onclick="edit(this)">编辑</a> ';  
                      var d = '<a href="${basePath}/news/delete?ID='+rec.ID+'">删除</a> ';  
                      return e+d;  
                  }  
                }  
          ]];
$(function(){
	initDatagrid('newsList','${basePath}/news/getNewsList','get',columns,$("#addDialog"));
	$('input[class="easyui-datetimebox"]').datetimebox({showSeconds: true});
	if(!flag){
		fileName=new Date().getTime();
		flag = true;
	}
	$("#imgPath").val(fileName);
	editor = initKindEditor(fileName,"${basePath}");
});
function edit(obj){
	var ID = $(obj).attr("id");
	$("#ifr").attr("src","${basePath}/news/getNewsByID?ID="+ID);
	$("#editDialog").dialog("open");
}
function colseDialog(){
	$("#editDialog").dialog("close");
}
$("#searchBtn").on("click",function(){
	var objs = $(".searchDiv .textbox-value");
	var startTime = $(objs[0]).val();
	var endTime = $(objs[1]).val();
	var searchTitle = $(".searchDiv #searchTitle").val();
	$("#newsList").datagrid("load", {"startTime":startTime,"endTime":endTime,"searchTitle":searchTitle});
});
</script>
</html>